package server

import (
	"shop/middleware"
	"strconv"
)

func SetToken(ID int) string {
	generateJWT, err := new(middleware.Claims).GenerateJWT(strconv.Itoa(ID))
	if err != nil {
		return ""
	}

	return generateJWT
}

func GetToken(token string) (string, error) {
	claims, err := new(middleware.Claims).ValidateJWT(token)
	if err != nil {
		return "", err
	}

	userID := claims.Id

	return userID, nil
}
